import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { View, TouchableOpacity, Text } from 'react-native';

import _styles from './styles';

export default class Item extends Component {
	static propTypes = {
		title: PropTypes.string, /* 筛选项标题 */
		icon: PropTypes.node,    /* icon元素 */
		onPress: PropTypes.func,  /* 点击事件方法 */
	}

	render() {
		const {title, icon, style = {}} = this.props;

		return (
			<TouchableOpacity
				style={[_styles.filterItem, style]}
				onPress={this.props.onPress}
			>
				<Text numberOfLines={1} style={{color: '#000'}}>
					{title}
					{ icon || null }
				</Text>
			</TouchableOpacity>
		);
	}
}